<?php

/**
 * XHTML_Table_Common_Element, xhtml_lib
 * 
 * This file contains the source code for the XHTML_Table_Common_Element class.
 * @author Fernando Jimenez Mocobono <fjmcool@gmail.com>
 * @version 0.1
 * @package xhtml_lib
 */

include_once "XHTML_Common_Element.php";

/**
 * The XHTML_Table_Common_Element class is a handler for the table 
 * xhtml-strict tag common inner elements as a part of a xhtml-strict 
 * php-handler implementation.
 */
abstract class XHTML_Table_Common_Element extends XHTML_Common_Element {
    
    // inner elements
    
    /**
     * The horizontal alignment chosen for the element.
     * Valid values: left, center, right, justify, char.
     * 
     * @var string
     */
    protected $align;
    
    /**
     * The char chosen as referenfece for the alignment. It only works when
     * $align == "char".
     *
     * @var string
     */
    protected $char;
    
    /**
     * The char offset to use for the alignment. It only works when
     * $align == "char".
     *
     * @var integer
     */
    protected $charOff;
    
    /**
     * The vertical aligment chosen for the element.
     * Valid values: top, middle, bottom, baseline.
     *
     * @var unknown_type
     */
    protected $valign;
    
    // Methods
    
    /**
     * Constructs a XHTML_B object.
     */
    function __construct()
    {
    }
    
    /**
     * Sets the alignment chosen for the element wich the CellHAlign object will
     * be in.
     * Valid values: left, center, right, justify, char;
     *
     * @param string $align
     */
    function setAlign($align)
    {
    	$this->align = $align;
    }
    
    /**
     * Gets the alignment chosen for the element wich the CellHAlign object will
     * be in.
     * Valid values: left, center, right, justify, char;
     *
     * @return string
     */
    function getAlign()
    {
    	return $this->align;
    }
    
    /**
     * Sets the char chosen as referenfece for the alignment. It only works when
     * $align == "char";
     *
     * @param string $char
     */
    function setChar($char)
    {
    	$this->char = $char;
    }
    
    /**
     * Gets the char chosen as referenfece for the alignment. It only works when
     * $align == "char";
     *
     * @return unknown
     */
    function getChar()
    {
    	return $this->char;
    }
    
    /**
     * Sets the char offset to use for the alignment. It only works when
     * $align == "char".
     *
     * @param integer $charOff
     */
    function setCharOff($charOff)
    {
    	$this->charOff = $charOff;
    }
    
    /**
     * Gets the char offset to use for the alignment. It only works when
     * $align == "char".
     *
     * @return integer
     */
    function getCharOff()
    {
    	return $this->charOff;
    }
    
    /**
     * Sets the vertical aligment chosen for the element.
     * Valid values: top, middle, bottom, baseline.
     *
     * @param string $valign
     */
    function setVAlign($valign)
    {
    	$this->valign = $valign;
    }
    
    /**
     * Gets the vertical aligment chosen for the element.
     * Valid values: top, middle, bottom, baseline.
     *
     * @return string
     */
    function getVAlign()
    {
    	return $this->valign;
    }
 
    // Overriding the toString method for a proper implementation.
    
    /**
    * Returns the string representation for echoing the class atributes.
    *
    * @return string
    */
    function toString()
    {
    	$auxString = parent::toString();
    	
    	if (isset($this->align)) {
    		$auxString = $auxString."align=\"".$this->align."\" ";
    		
    		if (isset($this->char)) {
    			$auxString = $auxString."char=\"".$this->char."\" ";
    		}
    	
    		if (isset($this->charOff)) {
    			$auxString = $auxString."charoff=\"".$this->charOff."\" ";
    		}
    	}
    	
    	if (isset($this->valign)) {
    		$auxString =$auxString."valign=\"".$this->valign."\" ";
    	}
                
        return $auxString;
    }
    
}

?>